package com.zjq.smartdevice.controller;

import com.zjq.smartdevice.dto.R;
import com.zjq.smartdevice.pojo.SysScene;
import com.zjq.smartdevice.service.SysSceneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.ExecutionException;

/**
 * @User zhangjiaqi
 * @Project project
 * @Package com.zjq.smartdevice.controller
 * @Date 2022/3/22 15:19
 */
@RestController
@RequestMapping("/scenes")
public class SysSceneController {

    private SysSceneService sysSceneService;

    @Autowired
    public void setSysSceneService(SysSceneService sysSceneService) {
        this.sysSceneService = sysSceneService;
    }

    @PostMapping("/scene")
    public R addScene(@RequestBody SysScene sysScene) {
        sysSceneService.addSysScene(sysScene);
        return R.setOK();
    }

    @GetMapping("/scene/{id}")
    public R findById(@PathVariable Long id) throws ExecutionException {

        return R.setOK(sysSceneService.findById(id));

    }
}
